package com.mypaper.main;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

import com.mypaper.dag.Benchmarks;
import com.mypaper.dag.DAG;
import com.mypaper.dag.DAGGenerator;
import com.mypaper.list.ListPriority;
import com.mypaper.schedule.HEFTSchedule;
import com.mypaper.schedule.HLDSchedule;
import com.mypaper.schedule.OptimizeSchedule;
import com.mypaper.schedule.RDDProSchedule;
import com.mypaper.schedule.RDDSchedule;


public class ScheduleSpec {

	/**
	 * @param args
	 */
public static void main(String[] args) throws IOException {	
		
		//Group 1
		/*short procNum=4,vertexNum=8;
		float[][] vertexWeight={{1,1,2,1},{3,2,4,2},{5,6,3,4},{2,4,4,2},
				{4,8,7,8},{3,3,1,2},{5,5,5,5},{1,2,2,2}};
		float[][] edgeWeight={{0,2,1,4,1,0,0,0},
				{0,0,0,0,0,8,0,0},
				{0,0,0,0,0,7,0,0},
				{0,0,0,0,0,2,10,0},
				{0,0,0,0,0,0,8,0},
				{0,0,0,0,0,0,0,5},
				{0,0,0,0,0,0,0,7},
				{0,0,0,0,0,0,0,0}};*/
			
		/*short procNum=4,vertexNum=13;
		float[][] vertexWeight={{2,2,2,2},
				{2,2,2,2},
				{2,2,2,2},
				{3,3,3,3},
				{1,1,1,1},
				{6,6,6,6},
				{2,2,2,2},
				{3,3,3,3},
				{2,2,2,2},
				{5,5,5,5},
				{2,2,2,2},
				{1,1,1,1},
				{1,1,1,1}};
		float[][] edgeWeight={{0,0,4,2,0,0,0,0,0,0,0,0,0},
				{0,0,1,0,0,0,0,6,0,0,0,0,0,0},
				{0,0,0,0,2,0,9,0,0,0,0,0,0},
				{0,0,0,0,1,5,2,1,0,0,0,0,0},
				{0,0,0,0,0,0,0,0,3,0,0,0,0},
				{0,0,0,0,0,0,0,0,2,2,4,0,0},
				{0,0,0,0,0,0,0,0,0,3,0,8,0},
				{0,0,0,0,0,0,0,0,0,0,7,9,0},
				{0,0,0,0,0,0,0,0,0,0,0,0,4},
				{0,0,0,0,0,0,0,0,0,0,0,0,1},
				{0,0,0,0,0,0,0,0,0,0,0,0,1},
				{0,0,0,0,0,0,0,0,0,0,0,0,0},
				{0,0,0,0,0,0,0,0,0,0,0,0,0}};*/
		
		/*short procNum=4,vertexNum=13;
		float[][] vertexWeight={{3,2,1,2},//1
				{1,3,1,3},//2
				{2,1,3,2},//3
				{2,3,4,1},//4
				{1,1,1,1},//5
				{5,8,7,4},//6
				{2,1,2,3},//7
				{4,3,2,3},//8
				{1,3,2,2},//9
				{6,3,4,7},//10
				{2,1,3,2},//11
				{2,3,4,1},//12
				{2,1,2,3}};//13
		float[][] edgeWeight={{0,0,4,2,0,0,0,0,0,0,0,0,0},
				{0,0,1,0,0,0,0,6,0,0,0,0,0},
				{0,0,0,0,2,0,9,0,0,0,0,0,0},
				{0,0,0,0,1,5,2,1,0,0,0,0,0},
				{0,0,0,0,0,0,0,0,3,0,0,0,0},
				{0,0,0,0,0,0,0,0,2,2,4,0,0},
				{0,0,0,0,0,0,0,0,0,3,0,8,0},
				{0,0,0,0,0,0,0,0,0,0,7,9,0},
				{0,0,0,0,0,0,0,0,0,0,0,0,4},
				{0,0,0,0,0,0,0,0,0,0,0,0,1},
				{0,0,0,0,0,0,0,0,0,0,0,0,1},
				{0,0,0,0,0,0,0,0,0,0,0,0,0},
				{0,0,0,0,0,0,0,0,0,0,0,0,0}};*/
	
	/*short procNum=4,vertexNum=13;
	float[][] vertexWeight={{3,2,4,2},//1
			{2,3,1,5},//2
			{2,1,3,2},//3
			{2,3,4,1},//4
			{4,2,3,5},//5
			{5,8,7,4},//6
			{2,1,2,3},//7
			{4,3,2,3},//8
			{1,3,2,2},//9
			{6,3,4,7},//10
			{2,1,3,2},//11
			{2,3,4,1},//12
			{2,1,2,3}};//13
	float[][] edgeWeight={{0,0,7,5,0,0,0,0,0,0,0,0,0},
			{0,0,3,0,0,0,0,6,0,0,0,0,0},
			{0,0,0,0,9,0,9,0,0,0,0,0,0},
			{0,0,0,0,6,5,2,3,0,0,0,0,0},
			{0,0,0,0,0,0,0,0,4,0,0,0,0},
			{0,0,0,0,0,0,0,0,3,2,4,0,0},
			{0,0,0,0,0,0,0,0,0,3,0,8,0},
			{0,0,0,0,0,0,0,0,0,0,7,9,0},
			{0,0,0,0,0,0,0,0,0,0,0,0,4},
			{0,0,0,0,0,0,0,0,0,0,0,0,3},
			{0,0,0,0,0,0,0,0,0,0,0,0,4},
			{0,0,0,0,0,0,0,0,0,0,0,0,0},
			{0,0,0,0,0,0,0,0,0,0,0,0,0}};
	
	/*short procNum=4,vertexNum=7;
	float[][] vertexWeight={{2,2,2,2},//1
			{3,3,3,3},//2
			{1,1,1,1},//3
			{3,3,3,3},//4
		    {5,5,5,5},//5
			{3,3,3,3},//6
			{2,2,2,2}};//7
	float[][] edgeWeight={{0,2,9,0,0,0,0},
			{0,0,0,6,7,14,0},
			{0,0,0,0,0,1,0},
			{0,0,0,0,0,0,13},
			{0,0,0,0,0,0,8},
			{0,0,0,0,0,0,12},
			{0,0,0,0,0,0,0}};*/
		//Group 2
		/*short procNum=3,vertexNum=10;
		float[][] vertexWeight={{22,15,17},{15,25,5},{22,5,9},{19,19,16},{16,20,24},{16,14,9},
				{15,12,21},{9,21,3},{5,6,25},{10,17,24}};
		float[][] edgeWeight={{0,18,10,6,10,14,0,0,0,0},
				{0,0,0,0,0,0,0,18,0,0},
				{0,0,0,0,0,0,22,0,0,0},
				{0,0,0,0,0,0,14,26,22,0},
				{0,0,0,0,0,0,0,0,10,0,0},
				{0,0,0,0,0,0,0,14,0,0},
				{0,0,0,0,0,0,0,0,0,18},
				{0,0,0,0,0,0,0,0,0,10},
				{0,0,0,0,0,0,0,0,0,14},
				{0,0,0,0,0,0,0,0,0,0}};*/
		/*
		 * 徐老师Group 3
		 */
		/*short procNum=3,vertexNum=8;
		float[][] edgeWeight={{0,11,17,14,11,0,0,0},
				{0,0,0,0,0,13,0,0},
				{0,0,0,0,0,10,0,0},
				{0,0,0,0,0,19,13,0},
				{0,0,0,0,0,0,27,0},
				{0,0,0,0,0,0,0,21},
				{0,0,0,0,0,0,0,13},
				{0,0,0,0,0,0,0,0}};
		float[][] vertexWeight={{11,13,9},{10,15,11},{9,12,14},{11,16,10},{15,11,19},
				{12,9,5},{10,14,13},{11,15,10}};*/
				
		//Group 4
		/*short procNum=4, vertexNum=10;
		float[][] vertexWeight={{41.55768f,92.530914f,31.081863f,26.105402f},	
				{3.6825438f,0.112928845f,32.29014f,47.66375f},	
				{41.15556f,52.51724f,13.917334f,80.55094f},
				{83.41398f,34.292557f,31.138144f,24.495823f},
				{5.4532723f,15.87779f,26.92726f,61.345318f},	
				{14.211864f,62.6854f,82.95699f,90.95349f},	
				{36.751556f,29.654287f,46.79768f,14.07127f},	
				{65.03401f,84.378296f,13.12177f,34.883797f},	
				{61.80082f,71.15469f,56.631786f,7.893405f},	
				{47.39652f,88.16024f,50.077183f,46.521797f}};
		
		float[][] edgeWeight={{0.0f,9.545559f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f},	
				{0.0f,0.0f,5.144695f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f},
				{0.0f,0.0f,0.0f,18.677172f,2.412945f,0.0f,0.0f,0.0f,0.0f,0.0f},	
				{0.0f,0.0f,0.0f,0.0f,0.0f,10.645799f,2.3019164f,0.0f,0.0f,0.0f},
				{0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,2.093592f,0.0f,0.0f,0.0f},
				{0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,17.419697f,0.0f,0.0f},
				{0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,3.7844737f,3.7692792f,0.0f},	
				{0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,3.1188953f},
				{0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,9.63106f},	
				{0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f}};
		
		//Group 5
		/*short procNum=4, vertexNum=10;
		float[][] vertexWeight={{41,92,31,26},	
				{3,1,32,47},	
				{41,52,13,80},
				{83,34,31,24},
				{5,15,26,61},	
				{14,62,82,90},	
				{36,29,46,14},	
				{65,84,13,34},	
				{61,71,56,7},	
				{47,88,50,46}};
		
		float[][] edgeWeight={{0,9,0,0,0,0,0,0,0,0},	
				{0,0,5,0,0,0,0,0,0,0},
				{0,0,0,18,2,0,0,0,0,0},	
				{0,0,0,0,0,10,2,0,0,0},
				{0,0,0,0,0,0,2,0,0,0},
				{0,0,0,0,0,0,0,17,0,0},
				{0,0,0,0,0,0,0,3,3,0},	
				{0,0,0,0,0,0,0,0,0,3},
				{0,0,0,0,0,0,0,0,0,9},	
				{0,0,0,0,0,0,0,0,0,0}};*/
		//产生DAG图中的通信及计算代价
		
		//Group 6
		
		short procNum=5,vertexNum=14;
		int[][] commDAG={{0,1,1,1,1,0,0,0,0,0,0,0,0,0},//1
				{0,0,0,0,0,1,0,0,0,0,0,0,0,0},//2
				{0,0,0,0,0,0,1,0,0,0,0,0,0,0},//3
				{0,0,0,0,0,0,0,1,0,0,0,0,0,0},//4
				{0,0,0,0,0,0,0,0,1,0,0,0,0,0,0},//5
				{0,0,0,0,0,0,1,1,1,0,0,0,0,0},//6
				{0,0,0,0,0,0,0,0,0,1,0,0,0,0},//7
				{0,0,0,0,0,0,0,0,0,0,1,0,0,0},//8
				{0,0,0,0,0,0,0,0,0,0,0,1,0,0},//9
				{0,0,0,0,0,0,0,0,0,0,1,1,0,0},//10
				{0,0,0,0,0,0,0,0,0,0,0,0,1,0},//11
				{0,0,0,0,0,0,0,0,0,0,0,0,0,1},//12
				{0,0,0,0,0,0,0,0,0,0,0,0,0,1},//13
				{0,0,0,0,0,0,0,0,0,0,0,0,0,0},//14
				};
		float CCR=1f;

		
		/*short procNum=4,vertexNum=41;
		float CCR=1f;
		                /*1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 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0,0,0,0,0,0,0,0,0,0,1,0,0,0,0},//32
				 		 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0},//33
				 		 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0},//34
				 		 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0},//35
				 		 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0},//36
				 		 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0},//37
				 		 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0},//38
				 		 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},//39
				 		 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},//40
				 		 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},//41
				 		 };
		
		
		//Group 9
		
		/*short procNum=5,vertexNum=14;
		float[][] vertexWeight={{74,54,27,28,34},
{33,29,55,55,30},
{68,37,61,32,27},
{42,51,36,29,31},
{57,29,33,43,74},
{52,74,26,39,47},
{39,60,57,28,30},
{55,42,57,51,71},
{43,56,42,29,72},
{60,31,40,64,30},
{71,60,35,55,35},
{37,39,59,43,37},
{69,50,57,46,70},
{58,46,72,63,48}};
		float[][] edgeWeight={{0,23.5f,36.5f,14.5f,30.5f,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,29.5f,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,15.5f,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,15.5f,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,25.5f,0,0,0,0},
{0,0,0,0,0,0,36.5f,13.5f,16.5f,18.5f,0,0,0,0},
{0,0,0,0,0,0,0,0,0,31.5f,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,33.5f,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,20.5f,0,0},
{0,0,0,0,0,0,0,0,0,0,21.5f,35.5f,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,12.5f,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,25.5f}, 
{0,0,0,0,0,0,0,0,0,0,0,0,0,16.5f}, 
{0,0,0,0,0,0,0,0,0,0,0,0,0,0}};*/

		FileOutputStream fos=null;
		OutputStreamWriter osw;
		int count=0;
		DAGGenerator dg=null;
		while(count<1){
			Benchmarks ben=new Benchmarks(vertexNum,procNum,commDAG,CCR);
			float[][] vertexWeight=ben.comp;
			float[][] edgeWeight=ben.comm;
		//while(flag==true){
			System.out.println("count="+count);	
			if(count==0){
				fos=new FileOutputStream("yu1.txt");	
			}
			osw=new OutputStreamWriter(fos);
			
			System.out.println("vertexWeight:");
			for(int i=0; i<vertexNum; i++){
				for(int j=0; j<procNum; j++){
					System.out.print(vertexWeight[i][j]+"  ");
				}
				System.out.println();
			}
			System.out.println();
			
			System.out.println("edgeWeight:");
			for(int i=0; i<vertexNum; i++){
				for(int j=0; j<vertexNum; j++){
					System.out.print(edgeWeight[i][j]+"  ");
				}
				System.out.println();
			}
			System.out.println();
				
			
			DAG dag=new DAG(vertexNum,procNum,vertexWeight,edgeWeight);	
			dag.calcBLPrior();
			ListPriority prior=dag.prior;
			dag.calcHCPrior();
			ListPriority priorHCP=dag.priorHCP;
			//HEFT算法
			float lowerResourse=0;
			for(int i=0; i<vertexNum; i++){
				float minWeightProc=Float.MAX_VALUE;
				for(int j=0; j<procNum; j++){
					if(minWeightProc>vertexWeight[i][j]){
						minWeightProc=vertexWeight[i][j];
					}
				}
				lowerResourse+=minWeightProc;
			}
			//prior.print();
			 //System.out.println("count="+count);
			HEFTSchedule heftSchedule=new HEFTSchedule(dag);//初始化
			heftSchedule.HEFT_Algorithm(dag);//调度
			float makespanHEFT=heftSchedule.makespan();//求makespan
			System.out.println("The makespan of HEFT is "+makespanHEFT);
			//HLD算法
			
			HLDSchedule hldSchedule=new HLDSchedule(vertexNum,procNum);//初始化调度	
			hldSchedule.HLD_Algorithm(vertexNum,procNum,prior,vertexWeight,edgeWeight);
			int duplNum_HLD=hldSchedule.duplNums(vertexNum);
			float makespanHLD=hldSchedule.makespan();
			System.out.println("The makespan of HLD is "+makespanHLD);
			float timeHLD=hldSchedule.timeCal(procNum);
			
			/*HCPFDSchedule hcpfdSchedule=new HCPFDSchedule(vertexNum, procNum);
			hcpfdSchedule.HCPFD_Algorithm(vertexNum,procNum,priorHCP,vertexWeight,edgeWeight);
			float makespanHCPFD=hcpfdSchedule.makespan();
			System.out.println("The makespan of HCPFD is "+makespanHCPFD);
			float timeHCP=hcpfdSchedule.timeCal(procNum);
			System.out.println();*/
			
			//long start=System.currentTimeMillis();
			RDDSchedule rddSchedule=new RDDSchedule(vertexNum,procNum,dag);//初始化调度	
			rddSchedule.RDD_Algorithm(vertexNum,procNum,prior,vertexWeight,edgeWeight,dag);
			float makespanRDD=rddSchedule.makespan();
			int duplNum_RDD=rddSchedule.duplNums(vertexNum);
			System.out.println("The makespan of RDD is "+makespanRDD);
			float timeRDD=rddSchedule.timeCal(procNum);
			
			RDDProSchedule rddProSchedule=new RDDProSchedule(vertexNum, procNum, dag);//初始化调度	
			rddProSchedule.RDDPro_Algorithm(vertexNum,procNum,prior,vertexWeight,edgeWeight,dag);
			float makespanRDDPro=rddProSchedule.makespan();
			int duplNum_RDDRro=rddProSchedule.duplNums(vertexNum);
			System.out.println("The makespan of RDDPro is "+makespanRDDPro);
			float timeRDDPro=rddProSchedule.timeCal(procNum);
			
			//OptimizeSchedule_back optSchedule=new OptimizeSchedule_back(dag.priorRever, dag.prior, rddSchedule, procNum, vertexNum);
			OptimizeSchedule optSchedule=new OptimizeSchedule(dag,dag.priorRever, dag.prior, rddSchedule, procNum, vertexNum);
			optSchedule.Optimize_Schedule(vertexNum, procNum, vertexWeight, edgeWeight, makespanRDD);
			//optSchedule.printSchedule(procNum, vertexNum);
			float makespanOpti=optSchedule.makespan(procNum);
			int duplNum_Opt=optSchedule.duplNums(vertexNum);
			System.out.println("The makespan of optimal is "+makespanOpti);
			float timeOpt=optSchedule.timeCal(procNum);
	
		
			OptimizeSchedule opt2Schedule=new OptimizeSchedule(dag,dag.priorRever, dag.prior, rddProSchedule, procNum, vertexNum);
			opt2Schedule.Optimize_Schedule(vertexNum, procNum, vertexWeight, edgeWeight, makespanRDDPro);
			//optSchedule.printSchedule(procNum, vertexNum);
			float makespanOpti2=optSchedule.makespan(procNum);
			int duplNum_Opt2=optSchedule.duplNums(vertexNum);
			System.out.println("The makespan of optimal2 is "+makespanOpti2);
			float timeOpt2=optSchedule.timeCal(procNum);
			
			//String s=String.valueOf(makespanHEFT+" "+lowerResourse+" "+makespanHLD+" "+timeHLD+" "+makespanRDD+" "+timeRDD+" "+makespanOpti+" "+timeOpt+"\n");       //把sum转化为字符
			String s=String.valueOf(makespanHEFT+" "+lowerResourse+" "+makespanHLD+" "+timeHLD+" "+makespanRDD+" "+timeRDD+" "+makespanRDDPro+" "+timeRDDPro+" "+makespanOpti+" "+timeOpt+" "+makespanOpti+" "+timeOpt+" "+duplNum_HLD+" "+duplNum_RDD+" "+duplNum_RDDRro+" "+duplNum_Opt+"\n");
			try{
			osw.write(s);	
			osw.flush();
			}catch(Exception e){}//结果在文本文档中显示不出来*/
			count++;
			
			/*if(makespanHEFT<makespanHLD){
				flag=false;
			}*/
		}
	}
}
